package com.xuecheng.content.api;

import com.xuecheng.content.model.dto.AddCourseTeacherDto;
import com.xuecheng.content.model.dto.SaveTeachplanDto;
import com.xuecheng.content.model.po.CourseTeacher;
import com.xuecheng.content.service.CourseTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Api(value = "师资管理接口",tags = "师资管理接口")
@RestController
@RequestMapping("/content")
public class CourseTeacherController {

    @Autowired
    private CourseTeacherService courseTeacherService;

    @ApiOperation("查询教师")
    @GetMapping("/courseTeacher/list/{id}")
    public CourseTeacher selectTeacher(@PathVariable Long id){
        CourseTeacher courseTeacher = courseTeacherService.selectTeacher(id);
        return courseTeacher;
    }

    @ApiOperation("新增教师")
    @PostMapping("/courseTeacher")
    public CourseTeacher addTeacher(@RequestBody @Validated AddCourseTeacherDto addCourseTeacherDto){
        CourseTeacher courseTeacher = courseTeacherService.addTeacher(addCourseTeacherDto);
        return courseTeacher;
    }

    @ApiOperation("修改教师")
    @PutMapping("/courseTeacher")
    public CourseTeacher editTeacher(@RequestBody CourseTeacher courseTeacher){
        CourseTeacher courseTeacher1 = courseTeacherService.editTeacher(courseTeacher);
        return courseTeacher1;
    }

    @ApiOperation("修改教师")
    @DeleteMapping("/courseTeacher/course/{courseId}/{id}")
    public void deleteTeacher(@PathVariable Long courseId , @PathVariable Long id){
        courseTeacherService.deleteTeacher(courseId, id);
    }

}
